---@class GT.abilityTip 技能提示
GT.abilityTip = class()

---@class abilityTip_data
---@field text Str 技能描述
---@field name Str 技能名字
---@field lv Str 技能等级
---@field icon Int32 技能图标
---@field cd Str 技能CD
---@field cost Str 技能消耗




---@param data abilityTip_data
function GT.abilityTip:ctor()
    self.ui = {}
    self.prefab = {}
    self.prefab["技能提示"] = GT.ui.prefab.obj({
        module = "c7478186-57df-4779-a36a-c19215a02a52",
        parent = "panel_2",
    })
    self.flushed={}

    local p = self.prefab["技能提示"]

    self.ui["self"] = p:child(GT.ui, "技能提示")
    self.ui["name"] = p:child(GT.ui.control.label, "name")
    self.ui["lv"] = p:child(GT.ui.control.label, "lv")
    self.ui["icon"] = p:child(GT.ui.control.image, "skill.icon")
    self.ui["cd"] = p:child(GT.ui.control.label, "cd")
    self.ui["cost"] = p:child(GT.ui.control.label, "cost")
    self.ui["text"] = p:child(GT.ui.control.label, "des.text")
    self.ui["des"] = p:child(GT.ui.control.scroll_view, "des")
    self.ui["self"].binding.x = 1736.0
    self.ui["self"].binding.y = 359.0

    
    self.y = self.ui["self"].y
    self:hide()
    
end

---转对象
---@return GT.abilityTip
function GT.abilityTip.obj()
    return new(GT.abilityTip)
end

---主动技能设置tip信息
---@param p GT.player
---@param data abilityTip_data
function GT.abilityTip:set(p, data)
    self.ui["text"].u[p.pid].binding.text = data.text
    self.ui["name"].u[p.pid].binding.text = data.name
    self.ui["lv"].u[p.pid].binding.text = "Lv." .. data.lv
    self.ui["icon"].u[p.pid].binding.img = data.icon
    self.ui["cd"].u[p.pid].binding.text = "冷却:" .. data.cd
    self.ui["cost"].u[p.pid].binding.text = "消耗:" .. data.cost
    self:show(p)
end



---显示
---@param p GT.player
function GT.abilityTip:show(p)
    if p ~= nil then
        self.ui["self"].u[p.pid].binding.show = true
    else
        self.ui["self"].binding.show = true
    end
end

---隐藏
function GT.abilityTip:hide(p)
    if p ~= nil then
        self.ui["self"].u[p.pid].binding.show = false

    else
        self.ui["self"].binding.show = false
    end
end


